package com.dahua;

import com.dahua.beanfactorypostprocessor.LubanBeanDefinitionRegistrarPostProcessor;
import com.dahua.luban.AppConfig;
import com.dahua.service.BeanService;
import com.dahua.zidingyisaomiaoqimofangmybatisdisanjieke.CustomScanner;
import com.dahua.zidingyisaomiaoqimofangmybatisdisanjieke.MyComponent;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.core.type.filter.AnnotationTypeFilter;

/**
 * @author chen_MingLiang
 * @version 1.0
 * @date 2019/10/15 23:17
 */
public class Test {
	public static void main(String[] args) {
		AnnotationConfigApplicationContext ioc
				= new AnnotationConfigApplicationContext(AppConfig.class);
		//下面这行代码就是AbstractApplicationContext类中PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(beanFactory, getBeanFactoryPostProcessors());-->
		//--第二个参数getBeanFactoryPostProcessors(),这里维护的是一个list,也就是说我这里添加一个Processor,在list里面就有了,可以断点试试
		//ioc.addBeanFactoryPostProcessor(new LubanBeanDefinitionRegistrarPostProcessor());
		System.out.println(ioc.getBean(AppConfig.class));
		//ioc.refresh();
		//CustomScanner customScanner = new CustomScanner(ioc);
		//这个方法不会把原来的@Component覆盖掉,会在list中追加
//		customScanner.addIncludeFilter(new AnnotationTypeFilter(MyComponent.class));
//		int count = customScanner.scan("com.dahua");
//		//这里打印2 我自己添加了两个@MyComponent注解的类,被扫描了出来
//		System.out.println(count);
		//ioc.getBean(BeanService.class);
	}
}
